package com.hhxy.login.schedule;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 此类定时任务测试专用
 */
//@Component
public class TimeView {
    private Logger logger = LoggerFactory.getLogger(TimeView.class);
    private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    private int count=0;
    @Scheduled(cron = "* * * * * ?")
    @Async("hhxyThreadPoolTaskExecutor")
    public void process(){
       logger.info("定时任务"+(count++));
    }

    @Scheduled(cron = "* * * * * ?")
    @Async("hhxyThreadPoolTaskExecutor")
    public void currentTime(){
        logger.info("现在时刻:"+simpleDateFormat.format(new Date()));
    }
}
